package com.bw.test;

import com.bw.bean.Shop;
import com.bw.dao.ShopDao;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class mmtest {
    @Test
    public  void show() throws IOException {
        InputStream resourceAsStream = Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(resourceAsStream);
        SqlSession sqlSession = build.openSession(true);
        ShopDao mapper = sqlSession.getMapper(ShopDao.class);
        List<Shop> list = mapper.show();
        for (Shop shop : list) {
            System.out.println(shop);
        }
    }
}
